const fs = require('fs');
const path = require('path');

function clearDirectory(dir) {
    fs.readdirSync(dir).forEach(file => {
        const currentPath = path.join(dir, file);
        if (fs.lstatSync(currentPath).isDirectory()) {
            // 递归删除子目录
            clearDirectory(currentPath);
        } else {
            // 删除文件
            fs.unlinkSync(currentPath);
        }
    });
}

module.exports.clearDirectory = clearDirectory;


